package com.digitalchina.lxnsy.activity.ecardConsult;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.kekstudio.dachshundtablayout.DachshundTabLayout;
import com.kekstudio.dachshundtablayout.indicators.LineMoveIndicator;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2018/8/1 14:09
 * 修改备注：
 * ================================================
 */
public class EcardConsultActivity extends BaseActivity {

    @Bind(R.id.tab_layout)
    DachshundTabLayout tabLayout;
    @Bind(R.id.viewPager)
    ViewPager viewPager;

    private String title[] = {"待回复", "已回复"};
    //类型 -1-全部 0-待回复 1-已回复
    private String type[] = {"0", "1"};
    private List<Fragment> fragments = new ArrayList<>();
    private MyPagerAdapter adapter;

    private final int REQUEST_IS_REFRESH = 99;

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_my_collect);
        setTitle("咨询列表");
    }

    @Override
    public void initMember() {

        tabLayout.setAnimatedIndicator(new LineMoveIndicator(tabLayout));

        for (int i = 0; i < title.length; i++) {
            EcardConsultFragment fragment = new EcardConsultFragment();
            fragments.add(fragment);
            Bundle bundle = new Bundle();
            bundle.putString("type", type[i]);
            fragment.setArguments(bundle);
        }

        adapter = new MyPagerAdapter(getSupportFragmentManager());
        viewPager.setOffscreenPageLimit(title.length);
        viewPager.setAdapter(adapter);

        viewPager.setOffscreenPageLimit(title.length);

        tabLayout.setupWithViewPager(viewPager);
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    private class MyPagerAdapter extends FragmentStatePagerAdapter {
        private MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return fragments.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return title[position];
        }

    }
    @Override
    public void rightOnClick() {
    }


}
